﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CNTVNow.Web.Models;
using CNTVNow.Web.Helpers.Common;

namespace CNTVNow.Web.Controllers
{
    public class SportController : BaseController
    {
        //
        // GET: /Sport/
        public ActionResult Index()
        {
            int menuId = string.IsNullOrEmpty(Request.QueryString["m"]) ? 0 : int.Parse(Request.QueryString["m"]);
            int parent = string.IsNullOrEmpty(Request.QueryString["p"]) ? 0 : int.Parse(Request.QueryString["p"]);
            if (menuId == 0 && parent == 0)
                Response.Redirect("../Home.cntv");
            Session["category"] = FixCommon.NewsSportId;
            try
            {
                ViewData["NewsBanner"] = SingletonContext.NewsModelInstance.GetNewsTopBanner(menuId, parent);
                ViewData["NewsUnderBanner"] = SingletonContext.NewsModelInstance.GetNewsUnderTopBanner(menuId, parent);
                ViewData["NewsLeft"] = SingletonContext.NewsModelInstance.GetNewsLeft(menuId, parent);
                ViewData["NewsMiddle"] = SingletonContext.NewsModelInstance.GetNewsMiddle(menuId, parent);

                ViewData["AdsTop"] = SingletonContext.NewsModelInstance.GetAdsItem(FixCommon.AdsSport, FixCommon.AdsTop);
                ViewData["AdsLeft"] = SingletonContext.NewsModelInstance.GetAdsItem(FixCommon.AdsSport, FixCommon.AdsLeft);
                ViewData["AdsRight"] = SingletonContext.NewsModelInstance.GetAdsItem(FixCommon.AdsSport, FixCommon.AdsRight);
            }
            catch
            { 
                //Future write log
            }
            return View();
        }

    }
}
